package com.woniuxy.common.factory;

import com.woniuxy.common.entity.Product;
import com.woniuxy.common.service.RemoteProductService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: 曾令忠
 * @Description:
 * @Date: 2020/7/12 0012-下午 3:02
 */
@Component
public class RemoteProductServiceFactory implements FallbackFactory {
    public RemoteProductService create(Throwable throwable) {
        return new RemoteProductService() {
            public List<Product> all() {
                Product product = new Product();
                product.setPname("商品模块异常");
                return Arrays.asList(product);
            }

            public String hi(String name) {
                return "商品模块不可用，请联系运维小哥处理";
            }
        };
    }
}
